/**
 *    Copyright 2009-2019 the original author or authors.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */
package org.apache.ibatis.annotations;

import org.apache.ibatis.mapping.ResultSetType;
import org.apache.ibatis.mapping.StatementType;

import java.lang.annotation.*;

/**
 * 声明语句的参数注解
 * @author Clinton Begin
 */
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Options {
    /**
     * 缓存刷新策略
     * The options for the {@link Options#flushCache()}.
     * The default is {@link FlushCachePolicy#DEFAULT}
     */
    enum FlushCachePolicy {
        /**
         * 默认 select不刷新缓存，insert/update/delete刷新缓存。
         */
        DEFAULT,
        /** 刷新缓存 */
        TRUE,
        /** 不刷新缓存 */
        FALSE
    }

    /**
     * 是否使用缓存
     */
    boolean useCache() default true;

    /**
     * 缓存刷新策略
     */
    FlushCachePolicy flushCache() default FlushCachePolicy.DEFAULT;

    /**
     * JDBC ResultSet类型
     */
    ResultSetType resultSetType() default ResultSetType.DEFAULT;

    /**
     * JDBC Statement类型
     */
    StatementType statementType() default StatementType.PREPARED;

    /**
     * 获取数据库内容大小限制
     */
    int fetchSize() default -1;

    /**
     * 驱动等待数据库返回结果的超时时间
     */
    int timeout() default -1;

    /**
     * 是否使用主键生成器
     */
    boolean useGeneratedKeys() default false;

    /**
     * 需要自动设值的属性名称集合
     */
    String keyProperty() default "";

    /**
     * 需要自动设值的列名称集合
     */
    String keyColumn() default "";

    /**
     * 多返回结果集名称配置
     */
    String resultSets() default "";
}
